<template>
  <a-modal
    :title="title"
    :width="width"
    :visible="visible"
    on-ok="handleOk"
    switch-fullscreen
    :ok-button-props="{ props: { disabled: disableSubmit } }"
    cancel-text="关闭"
    @ok="handleOk"
    @cancel="handleCancel"
  >
    <!--    <template slot="footer">-->
    <!--      <a-button key="back" @click="handleCancel">-->
    <!--        关闭-->
    <!--      </a-button>-->
    <!--      <a-button key="submit" type="primary" @click="handleOk">-->
    <!--        确定-->
    <!--      </a-button>-->
    <!--    </template>-->
    <leaving-message-form ref="realForm" :disabled="disableSubmit" @ok="submitCallback" />
  </a-modal>
</template>

<script>
import LeavingMessageForm from './LeavingMessageForm'

export default {
  name: 'TechnologyStackModal',
  components: {
    LeavingMessageForm
  },
  data() {
    return {
      title: '',
      width: 600,
      visible: false,
      disableSubmit: false
    }
  },
  methods: {
    add() {
      this.visible = true
      this.$nextTick(() => {
        this.$refs.realForm.add()
      })
    },
    edit(record) {
      this.visible = true
      this.$nextTick(() => {
        this.$refs.realForm.edit(record)
      })
    },
    handleOk(e) {
      this.$refs.realForm.submitForm()
    },
    handleCancel(e) {
      this.visible = false
    },
    submitCallback() {
      this.$emit('ok')
      this.visible = false
    }
  }
}
</script>
